<template>
	<view>
		<view class="header">
			<image src="@/static/zuo.png" mode="" style="width: 45upx;height: 45upx;" @click="back"></image>
			<text style="font-size: 36upx;margin-left: 30upx;color: #333;">毕业学校</text>
			<text style="font-size: 36upx;margin-left: 340upx;color: #333;" @click="queding">确定</text>
		</view>
		<view style="width: 690upx;height: 100upx;background-color: #fff;border-radius: 10upx;margin: 0 auto;margin-top: 150upx;display: flex;align-items: center;">
			<input type="text" placeholder="填写毕业院校" @input="soso" v-model="school_name" style="font-size: 26upx;padding-left: 18upx;">
		</view>
		<scroll-view scroll-y="true" class="xuexiao" v-if="isxue">
			<view v-for="(item, index) in leftList">
				<view class="" @click="nato(item.school_name,index)">
					<u-parse :html="school_name,item.school_name | toRed"
						style="width: 100%;height: 100upx;padding: 30upx;border-bottom: 2upx solid #EEEEEE;"></u-parse>
				</view>
			</view>
		</scroll-view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				school_name:'',
				isxue:false,
				leftList:[],
				school_id:'',
				useid:'',
				jiaoinfo:{},
				typename:""
			}
		},
		filters: {
			toRed: function(content, keyword) {
				var reslut = keyword.replace('' + content + '', "<text style='color:red;'>" + content + "</text>");
				return reslut;
			},
		},
		onLoad(option) {
			this.useid = option.useid
			if(option.sjan){
				this.jiaoinfo = JSON.parse(option.sjan)
			}
			this.typename = option.typename
			console.log(option.typename,"sadasdas")
		},
		methods: {
			queding(){
				if(this.typename == "增加"){

					uni.navigateTo({
						url:`./jiaoyujl?xuexiao=${this.school_name}&useid=${this.useid}`
					})
				}else{
					var jiaoinfo = JSON.stringify(this.jiaoinfo)
					console.log(jiaoinfo,"jiaoinfojiaoinfo")
					uni.navigateTo({
						url:`./jiaobian?xuexiao=${this.school_name}&useid=${this.useid}&sjan=${jiaoinfo}`
					})
				}
			},
			back(){
				uni.navigateBack({
					delta:1
				})
			},
			nato(name, index) {
				this.school_name = name
				this.school_id = this.leftList[index].id
				this.isxue = false
			},
			soso() {
				if (this.school_name !== '') {
					
					uni.request({
						url: 'https://dsx.cdzer.com/api/MemberInfo/search_school', //仅为示例，并非真实接口地址。
						method: 'POST',
						data: {
							school_name: this.school_name
						},
						header: {
							'content-type': 'application/x-www-form-urlencoded',
						},
						success: (res) => {
							console.log(res, "毕业学校")
							this.leftList = res.data.data
							if(this.leftList.length>0){
								this.isxue = true
							}
							
						}
					});
				} else {
					this.isxue = false
				}
			
			},
		}
	}
</script>

<style scoped lang="scss">
	.header {
		position: fixed;
		background-color: #fff;
		height: 110upx;
		width: 100%;
		top: 0;
		left: 0;
		display: flex;
		z-index: 100;
		align-items: center;
		padding-left: 30upx;
	}
.xuexiao {
		width: 100%;
		height: 755upx;
		background-color: #fff;
		position: fixed;
		bottom: 0;
		z-index: 6666;
	}
</style>
